import 'package:efood_multivendor/helper/responsive_helper.dart';
import 'package:efood_multivendor/helper/size_config.dart';
import 'package:efood_multivendor/util/dimensions.dart';
import 'package:efood_multivendor/view/base/rating_bar.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:shimmer_animation/shimmer_animation.dart';

class ProductShimmer extends StatelessWidget {
  final bool isEnabled;
  final bool isRestaurant;
  final bool hasDivider;
  ProductShimmer(
      {required this.isEnabled,
      required this.hasDivider,
      this.isRestaurant = false});

  @override
  Widget build(BuildContext context) {
    bool _desktop = ResponsiveHelper.isDesktop(context);

    return Shimmer(
      child: Container(
        padding: ResponsiveHelper.isDesktop(context)
            ? EdgeInsets.all(Dimensions.PADDING_SIZE_SMALL)
            : null,
        decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(Dimensions.RADIUS_SMALL),
          color: ResponsiveHelper.isDesktop(context)
              ? Theme.of(context).cardColor
              : null,
          boxShadow: ResponsiveHelper.isDesktop(context)
              ? [
                  BoxShadow(
                    color: Colors.grey[Get.isDarkMode ? 700 : 300]!,
                    spreadRadius: 1,
                    blurRadius: 5,
                  )
                ]
              : null,
        ),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Expanded(
              child: Padding(
                padding: EdgeInsets.symmetric(
                    vertical:
                        _desktop ? 0 : Dimensions.PADDING_SIZE_EXTRA_SMALL),
                child: Row(children: [
                  Container(
                    height: _desktop ? 120 : 250,
                    width: _desktop ? 120 : 90,
                    decoration: BoxDecoration(
                      borderRadius:
                          BorderRadius.circular(Dimensions.RADIUS_SMALL),
                      color: Colors.grey[300],
                    ),
                  ),
                  SizedBox(width: Dimensions.PADDING_SIZE_SMALL),
                  Expanded(
                    child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: [
                          Container(
                              height: _desktop ? 20 : 10,
                              width: 150,
                              color: Colors.grey[300]),
                          SizedBox(
                              height:
                                  Dimensions.PADDING_SIZE_EXTRA_SMALL * 0.2.h),
                          isRestaurant
                              ? Container(
                                  height: _desktop ? 15 : 10,
                                  width: 80,
                                  color: Colors.grey[300],
                                  margin: EdgeInsets.only(
                                      right: Dimensions.PADDING_SIZE_LARGE),
                                )
                              : Row(
                                  children: [
                                    Container(
                                      height: 5,
                                      width: 80,
                                      color: Colors.grey[300],
                                      margin: EdgeInsets.only(
                                          right: Dimensions.PADDING_SIZE_LARGE),
                                    ),
                                    Spacer(),
                                    // SizedBox(
                                    //     width:
                                    //         Dimensions.PADDING_SIZE_EXTRA_SMALL *
                                    //             20),
                                    Container(
                                      height: 30,
                                      width: 60,
                                      margin: EdgeInsets.only(
                                          right: Dimensions.PADDING_SIZE_LARGE),
                                      decoration: BoxDecoration(
                                        color: Colors.grey[300],
                                        borderRadius: BorderRadius.circular(
                                            Dimensions.RADIUS_SMALL),
                                      ),
                                    ),
                                  ],
                                ),

                          // SizedBox(
                          //     height: isRestaurant
                          //         ? Dimensions.PADDING_SIZE_SMALL
                          //         : 0),

                          SizedBox(
                              height:
                                  Dimensions.PADDING_SIZE_EXTRA_SMALL * 0.1.h),

                          Container(
                            height: _desktop ? 15 : 10,
                            width: 80,
                            color: Colors.grey[300],
                            margin: EdgeInsets.only(
                                right: Dimensions.PADDING_SIZE_LARGE),
                          ),
                          SizedBox(
                              height:
                                  Dimensions.PADDING_SIZE_EXTRA_SMALL * 0.1.h),

                          isRestaurant
                              ? Container(
                                  height: _desktop ? 15 : 10,
                                  width: 80,
                                  color: Colors.grey[300],
                                  margin: EdgeInsets.only(
                                      right: Dimensions.PADDING_SIZE_LARGE),
                                )
                              : SizedBox(),

                          // !isRestaurant ? RatingBar(rating: 0, size: _desktop ? 15 : 12, ratingCount: 0) : SizedBox(),
                          // isRestaurant ? RatingBar(
                          //   rating: 0, size: _desktop ? 15 : 12,
                          //   ratingCount: 0,
                          // ) : Row(children: [
                          //   Container(height: _desktop ? 20 : 15, width: 30, color: Colors.grey[300]),
                          //   SizedBox(width: Dimensions.PADDING_SIZE_EXTRA_SMALL),
                          //   Container(height: _desktop ? 15 : 10, width: 20, color: Colors.grey[300]),
                          // ]),
                        ]),
                  ),
                  // Column(
                  //     mainAxisAlignment: isRestaurant
                  //         ? MainAxisAlignment.center
                  //         : MainAxisAlignment.spaceBetween,
                  //     children: [
                  //       !isRestaurant
                  //           ? Padding(
                  //               padding: EdgeInsets.symmetric(
                  //                   vertical: _desktop
                  //                       ? Dimensions.PADDING_SIZE_SMALL
                  //                       : 0),
                  //               child: Icon(Icons.add, size: _desktop ? 30 : 25),
                  //             )
                  //           : SizedBox(),
                  //       Padding(
                  //         padding: EdgeInsets.symmetric(
                  //             vertical:
                  //                 _desktop ? Dimensions.PADDING_SIZE_SMALL : 0),
                  //         child: Icon(
                  //           Icons.favorite_border,
                  //           size: _desktop ? 30 : 25,
                  //           color: Theme.of(context).disabledColor,
                  //         ),
                  //       ),
                  //     ]),
                ]),
              ),
            ),
            _desktop
                ? SizedBox()
                : Padding(
                    padding: EdgeInsets.only(left: _desktop ? 130 : 90),
                    child: Divider(
                        color: hasDivider
                            ? Theme.of(context).disabledColor
                            : Colors.transparent),
                  ),
          ],
        ),
      ),
    );
  }
}
